package entity

import (
	"gorm.io/datatypes"
	"gorm.io/gorm"
	"time"
)

type SysRole struct {
	RoleId      uint32         `gorm:"role_id,primaryKey" json:"role_id" form:"role_id"`                           //
	ParentId    uint32         `gorm:"parent_id"       json:"parent_id" form:"parent_id"`                          // 父级角色ID
	Name        string         `gorm:"name,unique"     json:"name" form:"name" binding:"required"`                 // 角色定义名
	DisplayName string         `gorm:"display_name"    json:"display_name" form:"display_name" binding:"required"` // 角色显示名
	PermIds     datatypes.JSON `gorm:"perm_ids"        json:"perm_ids" form:"perm_ids" binding:"dive,required"`    // 角色权限数据，方便编辑
	Description string         `gorm:"description"     json:"description" form:"description"`                      // 角色描述
	OrderNum    uint32         `gorm:"order_num"       json:"order_num" form:"order_num" binding:"min=0"`          // 排序数字，值越小越靠前
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   gorm.DeletedAt `gorm:"index"`
}

//设置表名
func (e *SysRole) TableName() string {
	return "sys_roles"
}
